<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="common/common_head :: commonHeader('物料领用录入')"/>
    <link th:href="@{/static/css/plugins/cropper/cropper.min.css}" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <form class="form-horizontal" method="post" id="materialLead">
        <div class="row">
            <div class="form-group">
                <div class="col-sm-8" style="margin-left: 16px">
                    <input class="btn btn-primary" type="button" onclick="returnMaterial()" value="保存">
                    <button class="btn btn-primary" type="button" onclick="Dialog.closeFrame(window.name)">取 消</button>
                </div>
            </div>
            <!-- 显示 隐藏测试 -->
            <ul id="myTab" class="nav nav-tabs">
                <li class="active">
                    <a href="#basicinformation" linkTab="basicinformation" isActive="true" data-toggle="tab"> 基础信息</a>
                </li>
            </ul>
            <!-- 基本信息 -->
            <div id="basicinformation">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="col-xs-1 control-label">物料号：</label>
                            <div class="col-xs-3">
                                <input type="hidden" id="materialLeadId" name="materialLeadId" th:value="${materialLeadEntity.materialLeadId}">
                                <input id="materialCode" name="materialCode"
                                       th:value="${materialFactoryEntity.materialCode}" type="text" readonly="readonly"
                                       class="form-control">
                            </div>
                            <label class="col-xs-1 control-label">工厂：</label>
                            <div class="col-xs-3">
                                <input id="werks" name="werks" th:value="${materialFactoryEntity.werks}" type="text"
                                       readonly="readonly"
                                       class="form-control">
                            </div>
                            <label class="col-sm-1 control-label">可用数量：</label>
                            <div class="col-sm-3">
                                <input id="usecont" name="usecont" th:value="${materialFactoryEntity.usecont}"
                                       readonly="readonly"
                                       type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">库存地点：</label>
                            <div class="col-sm-3">
                                <input id="storageLocation" name="storageLocation"
                                       th:value="${materialFactoryEntity.storageLocation}" type="text"
                                       readonly="readonly"
                                       class="form-control">
                            </div>
                            <label class="col-sm-1 control-label">领用人：</label>
                            <div class="col-sm-3">
                                <input class="form-control required" th:value="${materialLeadEntity.leadMan}"
                                       id="leadMan" name="leadMan" readonly="readonly">
                            </div>
                            <label class="col-sm-1 control-label"><span class="required-sign">*</span>领用人部门：</label>
                            <div class="col-sm-3">
                                <input class="form-control required" th:value="${materialLeadEntity.leadDept}"
                                       id="leadDept" name="leadDept" readonly="readonly">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label"><span class="required-sign">*</span>领用数量：</label>
                            <div class="col-sm-3">
                                <input th:value="${materialLeadEntity.leadnum}" class="form-control" id="leadnum"
                                       name="leadnum" readonly="readonly"
                                       type="text">
                            </div>
                            <label class="col-sm-1 control-label">预计归还时间：</label>
                            <div class="col-sm-3">
                                <input class="form-control" th:value="${materialLeadEntity.returntime}" id="returntime"
                                       name="returntime" type="text" readonly="readonly">
                            </div>
                            <label class="col-sm-1 control-label"><span class="required-sign">*</span>发货人：</label>
                            <div class="col-sm-3">
                                <input class="form-control" th:value="${materialLeadEntity.account}" id="retrunman" name="retrunman" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label"><span class="required-sign">*</span>发货仓库：</label>
                            <div class="col-sm-3">
                                <select class="form-control" id="returnDept" name="returnDept" sysDict="KCDD"
                                        emptyFirst="false"></select>
                            </div>
                            <label class="col-sm-1 control-label"><span class="required-sign">*</span>发货数量：</label>
                            <div class="col-sm-3">
                                <input th:value="${materialLeadEntity.returnNum}" onchange="kucun()" class="form-control" id="returnNum"
                                       name="returnNum"
                                       type="number">
                            </div>
                            <label class="col-sm-1 control-label"><span class="required-sign">*</span>发货类型：</label>
                            <div class="col-sm-3">
                                <select class="form-control" id="returnType" name="returnType">
                                    <option th:value="2">新领料</option>
                                    <option th:value="1">试用归还</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>
</form>
</div>
<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<!-- Chosen -->
<script th:src="@{/static/js/plugins/chosen/chosen.jquery.js}"></script>
<script type="text/javascript">
    //初始化所有字典数据
    initDictDataSel();

    //保存
    function returnMaterial() {
        if ($("#materialLead").valid()) {
            Page.ajaxPOST(ctxPath + "/materialFactory/return", $('#materialLead').serialize(), function (res) {
                Dialog.msg("发货成功!", function () {
                    parent.refresh();
                    Dialog.closeFrame(window.name);
                });
            }, {"loadingMsg" : "正在往服务器提交数据……"});
        }
    }
    /**
     * @Description: 控制安全库存数量和库存数量
     */
    function kucun() {
        var leadnum = $("#leadnum").val();
        var returnNum = $("#returnNum").val();
        if (parseInt(returnNum) > parseInt(leadnum)) {
            Dialog.errorMsg("发货数量不可以大于领用数量!");
            $("#returnNum").val("");
        }
    }
</script>

</body>
</html>
